summaryrefslogtreecommitdiff
path: root/examples/with-content/src/pages/blog/[...slug].astro
diff options
context:
space:
mode:
Diffstat (limited to 'examples/with-content/src/pages/blog/[...slug].astro')
-rw-r--r--examples/with-content/src/pages/blog/[...slug].astro21
1 files changed, 21 insertions, 0 deletions
diff --git a/examples/with-content/src/pages/blog/[...slug].astro b/examples/with-content/src/pages/blog/[...slug].astro
new file mode 100644
index 000000000..c8e86c487
--- /dev/null
+++ b/examples/with-content/src/pages/blog/[...slug].astro
@@ -0,0 +1,21 @@
+---
+import { CollectionEntry, getCollection } from "astro:content";
+import BlogPost from "../../layouts/BlogPost.astro";
+
+export async function getStaticPaths() {
+ const posts = await getCollection('blog');
+ return posts.map(post => ({
+ params: { slug: post.slug },
+ props: post,
+ }));
+}
+type Props = CollectionEntry<'blog'>;
+
+const post = Astro.props;
+const { Content } = await post.render();
+---
+
+<BlogPost {...post.data}>
+ <h1>{post.data.title}</h1>
+ <Content />
+</BlogPost>